<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib prefix="stw" uri="http://stwitinc.com/jsp/tld/core"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>肾泰网-研发管理系统</title>
<stw:import type="jquery" src="/jquery" />
<stw:import type="bootstrap" src="/bootstrap" />
<stw:import type="script" src="/jquery/js/jquery.sha256.min.js" />
<script type="text/javascript">
	function login() {
		var userId = $("#userId").val();
		var password = $("#password").val();
		var ajaxOpts = {
			/* url : "${contextPath}/news/user/" + userId + "/login_state", */
			url : "${contextPath}/redmine/user/" + userId + "/login_state",
			method : "POST",
			data : {
				password : $.sha256(password)
			},
			dataType : "json",
			success : function(loginState) {
				if (loginState.responseCode == 0) {
					/* window.location.href = "${contextPath}/news/sys/management?tokenId=" + loginState.token.tokenId; */
				    /* alert("111"); */
					window.location.href = "${contextPath}/redmine/sys/management" ;
					
				} else if (loginState.responseCode == -1) {
					alert("用户不存在！");
				} else if (loginState.responseCode == -2) {
					alert("密码错误！");
				} else {
					alert("未知错误！");
				}
			},
			error : function(xhr, ts) {
				alert(ts);
			}
		};
		$.ajax(ajaxOpts);
	}
</script>
</head>
<body>
	<nav class="navbar navbar-default">
		<div class="container-fluid">
			<div class="navbar-header">
				<span class="navbar-brand">肾泰网-研发管理系统</span>
			</div>
		</div>
	</nav>
	<div class="panel panel-default" style="width: 400px; margin-left: auto; margin-right: auto;">
		<div class="panel-heading">登录</div>
		<div class="panel-body">
			<div class="form-group">
				<label for="userId">用户名</label><input type="text" class="form-control" id="userId" placeholder="用户名">
			</div>
			<div class="form-group">
				<label for="password">密码</label><input type="password" class="form-control" id="password" placeholder="密码">
			</div>
			<button class="btn btn-default" onclick="login();">登录</button>
		</div>
	</div>
</body>
</html>